﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.DAL;

namespace WXYW
{
    public partial class AddRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void saveLnk_Click(object sender, EventArgs e)
        {
            try
            {
                RoleService roleService = new RoleService();
                UserType role = new UserType();
                role.Name = roleNameTxtBox.Text;
                role.Description = roleDescription.Text;
                role.ID = roleService.GetCountOfUserType() + 1;                
                roleService.AddRole(role);
                Response.Write(string.Format("<script language='JavaScript'> alert( '角色\"{0}\"已被成功添加，请为此角色配置相应的权限！');location.href= 'ManageRole.aspx' </script> ", roleNameTxtBox.Text)); 
            }
            catch (Exception ex)
            {
                LogUtility.LogUtilityIntance.LogException(ex, string.Format("AddRole -> saveLnk_Click: {0}, {1}", roleNameTxtBox.Text, roleDescription.Text));
            }
        }
    }
}
